package com.panshi.repast.JsonAppbean;

import java.util.List;

import com.alibaba.fastjson.JSON;

/**
 * 获取数据并转换为appbean
 * 
 * @author huang
 * 
 */

@SuppressWarnings("rawtypes")

public class GetJsonAppean<T> {

	private static GetJsonAppean getjsonappbean = null;

	/**
	 * 单列模式获取实列化
	 * 
	 * @param context
	 * @return
	 */
	public static GetJsonAppean getInstance() {
		if (getjsonappbean == null) {
			getjsonappbean = new GetJsonAppean();
		}
		return getjsonappbean;
	}
	
	/**
	 * 将Json数据转换为实体类
	 * 
	 * @param json
	 * @param T
	 * @return
	 */
	public T getJsonAppbean(String json,Class<T> T){
		return JSON.parseObject(json, T);
	}
	
	/**
	 * 返回Json数据转换为数组实体类
	 * 
	 * @param json
	 * @param List<T>
	 * @return
	 */
	public List<T> getJsonArrayAppbean(String json,Class<T> T){
		return JSON.parseArray(json, T);
	}

}
